// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: GHZ Setup Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

public alias  256 		: GROUP_PLAYERS
public alias  65536 	: HITBOX_AUTO
public alias  arrayPos6 : currentPlayer

//-------Aliases-------//

private alias Object.Value0 : Object.Timer
private alias Object.Value1 : Object.AltTimer

//Background

private alias Object.Value2 : bg.scrollfront
private alias Object.Value3 : bg.scrollback
private alias Object.Value4 : background.timer
private alias Object.Value5 : bg.alpha

//Hud Bar

private alias Object.Value6 : HUD.Ypos
private alias Object.Value7 : HUD.Slider

//Extra

private alias Object.Value8 : Screen.AdjustX
private alias Object.Value9 : Screen.AdjustY

private alias Object.Value10 : Object.charY

//Players

private alias Object.Value11 : Player.Xpos
private alias Object.Value12 : Slender.Xpos

//Text

private alias object.value13 : object.index

private alias object.value14 : object.drawX
private alias object.value15 : object.drawY
private alias object.value16 : object.letter
private alias object.value17 : object.charamount

//idk

private alias Object.Value18 : Options.Ypos
private alias Object.Value19 : Options.Slider
private alias Object.Value20 : Options.AdjustY
private alias Object.Value21 : Options.Selected
private alias Object.Value22 : Options.State

private alias Object.Value23 : Menu.AttackBar
private alias Object.Value24 : Menu.AttackDamage
private alias Object.Value25 : Menu.AttackRadius
private alias Object.Value26 : Menu.AttackLowerR

private alias Object.Value27 : Menu.DmgNumberY

private alias Object.Value28 : Object.TableContainer


private alias Object.Value29 : Object.TableTimer
private alias Object.Value30 : Slender.AnimTimer

//Soul

private alias Object.Value31 : Text.Proceed	//those who
private alias Object.Value32 : Act.Selection
private alias Object.Value33 : Object.AttackTimer
private alias Object.Value34 : Item.Selection

private alias Object.Value35 : Mercy.Attack
private alias Object.Value36 : Mercy.NumberY

private alias Object.Value37 : Attack.Property
private alias Object.Value38 : Final.Fade

private alias Object.Value39 : Freddy.Xpos
private alias Object.Value40 : Object.TouchTimer
private alias Object.Value41 : Object.TextProgress
private alias Object.Value42 : Object.TalkingChar
private alias Object.Value43 : Object.LowText
private alias Object.Value44 : Object.AttackOrder
private alias Object.Value45 : Object.RingUsage
private alias Object.Value46 : Object.Flirted
private alias Object.Value47 : Object.BoxLength

private alias object[2].value16 : SSonic.PauseState
public alias saveRAM[286] : saved.language

// State aliases
private alias 0  : DELTA_WAIT_0
private alias 1  : DELTA_ALERT_1
private alias 2  : DELTA_START_2
private alias 3  : DELTA_BATTLEIDLE_3
private alias 4  : DELTA_DIALOGUE_4
private alias 5  : DELTA_ATTACKSTART_5
private alias 6  : DELTA_ATTACKING_6
private alias 7  : DELTA_ATTACKEND_7

private alias 8  : DELTA_BATTLEEND_8
private alias 9  : DELTA_FINALDIALOGUE_9

private alias 90  : DELTA_DIED_90	//black screen
private alias 91  : DELTA_DIED_FADEIN_91	//fade in game over
private alias 92  : DELTA_DIED_GAMEOVER_92	//fade in game over

// Menu aliases
private alias 0  : DELTAMENU_FIGHT_0
private alias 1  : DELTAMENU_ACT_1
private alias 2  : DELTAMENU_ITEM_2
private alias 3  : DELTAMENU_SPARE_3
private alias 4  : DELTAMENU_DEFEND_4

//Option States
private alias 0  : DELTAOPT_CHOOSING_0

private alias 1  : DELTAOPT_FIGHT_PICKTARGET_1
private alias 2  : DELTAOPT_FIGHT_ATTACKING_2	//the bar
private alias 3  : DELTAOPT_FIGHT_RESULTS_3	//the effects of hitting
private alias 4  : DELTAOPT_FIGHT_EFFECTS_4	//numbers and proceeding to slendermans turn

private alias 5  : DELTAOPT_ACT_PICKTARGET_5
private alias 6  : DELTAOPT_ACT_CHOOSEACT_6

private alias 7  : DELTAOPT_ITEM_CHOOSEITEM_7
private alias 8  : DELTAOPT_ITEM_USEITEM_8

private alias 9  : DELTAOPT_SPARE_CHOOSETARGET_9
private alias 10  : DELTAOPT_SPARE_MERCYCHECK_10


reserve function Delta_BG
reserve function Delta_HUD
reserve function Delta_TextDrawing
reserve function Delta_PlayerHUD
reserve function Delta_TalkingText
reserve function AutoMobile
reserve function Delta_TouchDraw


//public value Delta_TextProgression = 0;
//public value Delta_IsTalking = 0;
//public value Delta_BottomText = 0;
//public value Delta_RingsUsed = 0;
//public value Delta_AttackOrder = 0;
//public value Delta_ActFlirted = 0;
public value Delta_TP = 0;	//ok this used but unused, theres no special tp acts lol

public value Delta_HP = 90;
public value Delta_YourTurn = 1;

public value Delta_SlenderHP = 100;
public value Delta_SlenderMercy = 0;

public value Delta_BecomeGreen = 0;

public value Delta_ShowMercy = 0;

public value Delta_Defending = 0;
public value Delta_Attacker = 0;		//0	= S;	1 = F

public value Delta_AttackHardMode = 0;
public value PlayerDied = 0;
public value SlenderSpared = 0;
public value Delta_Activate = 0;

public alias saveRAM[295]: saved.mobile

public alias saveRAM[6905] : saved.SlenderOST

public table NumberBounce
	2, 3, 2, 0, 2, 3, 2, 0, 2, 3, 2, 0, 1, 0, 0
end table

public table SlenderBounce
	0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -2, 0, 1, 0, 0,
end table

//IMPORTANT KEYS:

//Delta_TextProgression

//Ending: Spared
//99 - 105

//Ending: Killed
//106-


function AutoMobile
	CheckTouchRect(0, 0, screen.xsize, screen.ysize)
	if checkResult == -1
		Object.TouchTimer = false
	end if
	if Object.TouchTimer == 0
		CheckTouchRect(0, 96, screen.xcenter, screen.ysize)
		if checkResult > -1
			arrayPos0 = checkResult
			temp0 = touchscreen[arrayPos0].xpos
			temp0 -= 56
			temp1 = touchscreen[arrayPos0].ypos
			temp1 -= 184
			ATan2(temp2, temp0, temp1)
			temp2 += 16
			temp2 &= 255
			temp2 >>= 5
			if object.state == DELTA_ATTACKING_6
				switch temp2
				case 0
					inputdown[currentPlayer].right = true
					break
				case 1
					inputdown[currentPlayer].right = true
					inputdown[currentPlayer].down = true
					break
				case 2
					inputdown[currentPlayer].down = true
					break
				case 3
					inputdown[currentPlayer].down = true
					inputdown[currentPlayer].left = true
					break
				case 4
					inputdown[currentPlayer].left = true
					break
				case 5
					inputdown[currentPlayer].left = true
					inputdown[currentPlayer].up = true
					break
				case 6
					inputdown[currentPlayer].up = true
					break
				case 7
					inputdown[currentPlayer].up = true
					inputdown[currentPlayer].right = true
					break
				end switch
			else
				switch temp2
				case 0
					inputPress[currentPlayer].right = true
					break
				case 1
					inputPress[currentPlayer].right = true
					inputPress[currentPlayer].down = true
					break
				case 2
					inputPress[currentPlayer].down = true
					break
				case 3
					inputPress[currentPlayer].down = true
					inputPress[currentPlayer].left = true
					break
				case 4
					inputPress[currentPlayer].left = true
					break
				case 5
					inputPress[currentPlayer].left = true
					inputPress[currentPlayer].up = true
					break
				case 6
					inputPress[currentPlayer].up = true
					break
				case 7
					inputPress[currentPlayer].up = true
					inputPress[currentPlayer].right = true
					break
				end switch
				Object.TouchTimer = 1
			end if
		end if
		CheckTouchRect(screen.xcenter, 96, screen.xsize, 240)
		if checkResult > -1
			inputDown.buttonA = 1
			Object.TouchTimer = 1
		end if
		if touchJump == 0
			inputPress.buttonA |= inputDown.buttonA
		end if
		touchJump = inputDown.buttonA
		
		CheckTouchRect(0, 0, 122, 56)
		if checkResult > -1
			inputDown.buttonB = 1
		end if
		if touchDebug == 0
			inputPress.buttonB |= inputDown.buttonB
		end if
		touchDebug = inputDown.buttonB
	
	end if
end function

function Delta_TouchDraw

	temp0 = screen.xsize
	temp0 -= 44
	DrawSpriteScreenFX(193, FX_INK, 26,1 49) //dpad
	temp0 -= 39

	//movement
	
	temp0 -= 10
	if inputDown.Left==1
		DrawSpriteScreenFX(196,  FX_INK, 26, 151)
	endif
	if inputDown.Down==1
		DrawSpriteScreenFX(195,  FX_INK, 26, 189)
	end if
	if inputDown.Right==1
		DrawSpriteScreenFX(197, FX_INK, 64, 151)
	endif
	if inputDown.Up==1
		DrawSpriteScreenFX(194,  FX_INK, 26, 151)
	endif
	
	temp0 += 15	
	//jump
	if inputDown.buttonA==1
		DrawSpriteScreenFX(199,FX_INK,  temp0, 163)	
	else
		DrawSpriteScreenFX(198, FX_INK, temp0, 163)
	endif

	if inputDown.buttonB==1
		DrawSpriteScreenFX(201, FX_INK, 32, 6)	
	else
		DrawSpriteScreenFX(200, FX_INK, 32, 6)
	endif

	
end function

function AutoMobile
	CheckTouchRect(0, 0, screen.xsize, screen.ysize)
	if checkResult == -1
		Object.TouchTimer = false
	end if
	if Object.TouchTimer == 0
		CheckTouchRect(0, 96, screen.xcenter, screen.ysize)
		if checkResult > -1
			arrayPos0 = checkResult
			temp0 = touchscreen[arrayPos0].xpos
			temp0 -= 56
			temp1 = touchscreen[arrayPos0].ypos
			temp1 -= 184
			ATan2(temp2, temp0, temp1)
			temp2 += 16
			temp2 &= 255
			temp2 >>= 5
			if object.state == DELTA_ATTACKING_6
				switch temp2
				case 0
					inputdown[currentPlayer].right = true
					break
				case 1
					inputdown[currentPlayer].right = true
					inputdown[currentPlayer].down = true
					break
				case 2
					inputdown[currentPlayer].down = true
					break
				case 3
					inputdown[currentPlayer].down = true
					inputdown[currentPlayer].left = true
					break
				case 4
					inputdown[currentPlayer].left = true
					break
				case 5
					inputdown[currentPlayer].left = true
					inputdown[currentPlayer].up = true
					break
				case 6
					inputdown[currentPlayer].up = true
					break
				case 7
					inputdown[currentPlayer].up = true
					inputdown[currentPlayer].right = true
					break
				end switch
			else
				switch temp2
				case 0
					inputPress[currentPlayer].right = true
					break
				case 1
					inputPress[currentPlayer].right = true
					inputPress[currentPlayer].down = true
					break
				case 2
					inputPress[currentPlayer].down = true
					break
				case 3
					inputPress[currentPlayer].down = true
					inputPress[currentPlayer].left = true
					break
				case 4
					inputPress[currentPlayer].left = true
					break
				case 5
					inputPress[currentPlayer].left = true
					inputPress[currentPlayer].up = true
					break
				case 6
					inputPress[currentPlayer].up = true
					break
				case 7
					inputPress[currentPlayer].up = true
					inputPress[currentPlayer].right = true
					break
				end switch
				Object.TouchTimer = 1
			end if
		end if
		CheckTouchRect(screen.xcenter, 96, screen.xsize, 240)
		if checkResult > -1
			inputDown.buttonA = 1
			Object.TouchTimer = 1
		end if
		if touchJump == 0
			inputPress.buttonA |= inputDown.buttonA
		end if
		touchJump = inputDown.buttonA
		
		CheckTouchRect(0, 0, 122, 56)
		if checkResult > -1
			inputDown.buttonB = 1
		end if
		if touchDebug == 0
			inputPress.buttonB |= inputDown.buttonB
		end if
		touchDebug = inputDown.buttonB
	
	end if
end function

function Delta_TalkingText

	
	temp0 = object.drawX
	temp1 = object.charamount
	while temp1 > 0
	// Get the actual character at the current char pos
	GetTextInfo(object.letter, 0, TEXTINFO_TEXTDATA, Object.Index, ArrayPos0)

	Object.Frame = 107
	
	// Take uppercase letters and turn them into a matching Sprite Frame
	if object.letter > 64
		if object.letter < 91
			Object.Frame  = object.letter
			Object.Frame += 42
		end if
	end if
	
	// Take lowercase letters and turn them into a matching Sprite Frame
	if object.letter > 96
		if object.letter < 123
			Object.Frame  = object.letter
			Object.Frame += 36
		end if
	end if

		//ASCII Table required!
		switch object.letter
			case 32	//Space
				ArrayPos0++
				temp1--
				object.drawX += 0x6
			break
			case 33	//!
				DrawSpriteScreenFX(186, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break		
			case 63	//?
				DrawSpriteScreenFX(185, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break			
			case 39	//'
				DrawSpriteScreenFX(191, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break						
			case 42	//*
				DrawSpriteScreenFX(27, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break
			case 44	//,
				DrawSpriteScreenFX(40, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break		
			case 45	//,
				DrawSpriteScreenFX(203, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break				
			case 46	//.
				DrawSpriteScreenFX(190, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break			
			case 58	//:
				DrawSpriteScreenFX(43, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break		
			case 51	// 3
				DrawSpriteScreenFX(47, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break		
			case 52// 4
				DrawSpriteScreenFX(48, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break							
			case 57	// 9
				DrawSpriteScreenFX(53, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x6
				break	
			case 64	//@	LINE SKIPPER
				object.drawY += 10
			
				temp0 -= 6
				object.drawX = temp0
				

				// Move to the next letter
				ArrayPos0++
				
				// And decrease the remaining letter count, as well
				temp1--
			break
			default
			// Notably, the space character (32) is skipped over here, as it shouldn't draw anything
			

			DrawSpriteScreenFX(Object.Frame, FX_INK, object.drawX, object.drawY)

			// Move to the next letter
			ArrayPos0++
			
			// And decrease the remaining letter count, as well
			temp1--
			
			// Each letter should be spaced 8 pixels apart
			object.drawX += 0x6
			break
		end switch
	loop
end function

function Delta_PlayerHUD
	//Player Bar
	temp0 = screen.xcenter
	temp0 -= 5
	switch stage.playerlistpos
		case 0
			DrawSpriteScreenXY(56, temp0, Options.Ypos)
		break
		case 1
			DrawSpriteScreenXY(57, temp0, Options.Ypos)
		break
		case 2
			DrawSpriteScreenXY(58, temp0, Options.Ypos)
		break
		case 5
			DrawSpriteScreenXY(59, temp0, Options.Ypos)
		break						
	end switch
	//HP Numbers
	temp0 += 4
	Options.Ypos += 2
	if Delta_HP > 0
		DrawNumbers(60, temp0, Options.Ypos, Delta_HP, 3, 4, 0)
	else
		DrawNumbers(60, temp0, Options.Ypos, 0, 3, 4, 0)
	end if

	//HP the rect


	temp1 = screen.xcenter
	temp1 += 11
	temp2 = Options.Ypos
	temp2 -= 36
	temp3 = 40
	temp3 *= Delta_HP
	temp3 /= 90
	temp3 %= 90
	
	switch stage.playerlistpos
		case 0
			DrawRect(temp1, temp2, temp3, 5, color1, color2, color6, 255)
		break
		case 1
			DrawRect(temp1, temp2, temp3, 5, color7, color4, 0, 255)
		break		
		case 2
			DrawRect(temp1, temp2, temp3, 5, color6, 0, color1, 255)
		break		
		case 5
			DrawRect(temp1, temp2, temp3, 5, color6, color2, color5, 255)
		break		
	end switch

	temp0 = screen.xcenter

	switch Options.Selected
	case DELTAMENU_FIGHT_0
		temp0 -= 46
		DrawSpriteScreenXY(70, temp0, Options.Ypos)
	break
	case DELTAMENU_ACT_1
		temp0 -= 27
		DrawSpriteScreenXY(71, temp0, Options.Ypos)
	break
	case DELTAMENU_ITEM_2
		temp0 -= 7
		DrawSpriteScreenXY(72, temp0, Options.Ypos)
	break	
	case DELTAMENU_SPARE_3
		temp0 += 12
		DrawSpriteScreenXY(73, temp0, Options.Ypos)
	break		
	case DELTAMENU_DEFEND_4
		temp0 += 32
		DrawSpriteScreenXY(74, temp0, Options.Ypos)
	break		
	end switch

end function

function Delta_HUD
	temp4 = screen.ycenter
	temp4 += 240
	//Scrolling
	HUD.Slider = temp4
	HUD.Slider -= screen.ycenter
	HUD.Slider /= 8
	HUD.Slider += 24
	temp1 = HUD.Slider
	temp1 -= object.charY
	temp2 = temp1
	Abs(temp2)

	//Make sure it's exactly in the spot
	if temp2 < 6
		if object.charY > HUD.Slider
			object.charY--
		else
			if object.charY < HUD.Slider
				object.charY++
			else
				object.charY = HUD.Slider
			end if
		end if
	else
		temp1 >>= 2
		object.charY += temp1
	end if

	temp4 = object.charY
	temp4 += screen.ycenter
	HUD.Ypos = temp4
	HUD.Ypos -= 2



	temp4 = screen.ycenter
	temp4 += 240
	//Scrolling
	Options.Slider = temp4
	Options.Slider -= screen.ycenter
	Options.Slider /= 8
	Options.Slider += 24
	temp1 = Options.Slider
	temp1 -= Options.AdjustY
	temp2 = temp1
	Abs(temp2)

	//Make sure it's exactly in the spot
	if temp2 < 6
		if Options.AdjustY > Options.Slider
			Options.AdjustY--
		else
			if Options.AdjustY < Options.Slider
				Options.AdjustY++
			else
				Options.AdjustY = Options.Slider
			end if
		end if
	else
		temp1 >>= 2
		Options.AdjustY += temp1
	end if

	temp4 = Options.AdjustY
	temp4 += screen.ycenter
	Options.Ypos = temp4

	if Delta_YourTurn == 1
		Options.AdjustY += 3
	else
		Options.AdjustY += 15
	end if
	

end function

function Delta_BG	
	switch object.state
	case DELTA_WAIT_0
	case DELTA_ALERT_1
	case DELTA_START_2
		object.InkEffect = INK_ALPHA
		DrawRect(0, 0, screen.xsize, screen.ysize, 0x00, 0x00, 0x00, bg.alpha)

		background.timer++
		if background.timer == 2
			//so it always reaches the edge
			bg.scrollback++
			bg.scrollback &= 63
			background.timer = 0
		end if
		temp0 = bg.scrollback
		temp0 -= 64
		while temp0 < screen.ysize
			temp1 = temp0
			temp1 -= screen.xcenter
			while temp1 < screen.xsize
				DrawSpriteScreenFX(45, FX_INK, temp1, temp0)
				temp1 += 64		
			loop
			temp0 += 64
		loop	
			
		//so it always reaches the edge
		bg.scrollfront++
		bg.scrollfront &= 63
		temp0 = bg.scrollfront
		flipsign(temp0)
		while temp0 < screen.ysize
			temp1 = temp0
			temp1 -= screen.xcenter
			while temp1 < screen.xsize
				DrawSpriteScreenFX(44, FX_INK, temp1, temp0)
				temp1 += 64		
			loop
			temp0 += 64
		loop	
	break
	default	//try not to use transparency, so we can use it for other things!
		object.InkEffect = INK_ALPHA
		DrawRect(0, 0, screen.xsize, screen.ysize, 0x00, 0x00, 0x00, 255)

		background.timer++
		if background.timer == 2
			//so it always reaches the edge
			bg.scrollback++
			bg.scrollback &= 63
			background.timer = 0
		end if
		temp0 = bg.scrollback
		temp0 -= 64
		while temp0 < screen.ysize
			temp1 = temp0
			temp1 -= screen.xcenter
			while temp1 < screen.xsize
				DrawSpriteScreenXY(45, temp1, temp0)
				temp1 += 64		
			loop
			temp0 += 64
		loop	
			
		//so it always reaches the edge
		bg.scrollfront++
		bg.scrollfront &= 63
		temp0 = bg.scrollfront
		flipsign(temp0)
		while temp0 < screen.ysize
			temp1 = temp0
			temp1 -= screen.xcenter
			while temp1 < screen.xsize
				DrawSpriteScreenXY(44, temp1, temp0)
				temp1 += 64		
			loop
			temp0 += 64
		loop	
	break
	end switch	
end function



function Delta_TextDrawing

	
	temp0 = object.drawX
	temp1 = object.charamount
	while temp1 > 0
	// Get the actual character at the current char pos
	GetTextInfo(object.letter, 0, TEXTINFO_TEXTDATA, Object.Index, ArrayPos0)

	Object.Frame = 0
	
	// Take uppercase letters and turn them into a matching Sprite Frame
	if object.letter > 64
		if object.letter < 91
			Object.Frame  = object.letter
			Object.Frame -= 64
		end if
	end if
	
	// Take lowercase letters and turn them into a matching Sprite Frame
	if object.letter > 96
		if object.letter < 123
			Object.Frame  = object.letter
			Object.Frame -= 96
		end if
	end if

		//ASCII Table required!
		switch object.letter
			case 33	//!
				DrawSpriteScreenFX(28, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break		
			case 63	//?
				DrawSpriteScreenFX(29, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break			
			case 39	//''
				DrawSpriteScreenFX(42, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break						
			case 42	//*
				DrawSpriteScreenFX(27, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break
			case 44	//,
				DrawSpriteScreenFX(40, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break		
			case 46	//.
				DrawSpriteScreenFX(41, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break			
			case 58	//:
				DrawSpriteScreenFX(43, FX_INK, object.drawX, object.drawY)
				ArrayPos0++
				temp1--
				object.drawX += 0x8
				break		
			case 48; DrawSpriteScreenFX(160, FX_INK, object.drawX, object.drawY); ArrayPos0++; temp1--; object.drawX += 0x8; break	//0
			case 49; DrawSpriteScreenFX(161, FX_INK, object.drawX, object.drawY); ArrayPos0++; temp1--; object.drawX += 0x8; break	//1		
			case 50; DrawSpriteScreenFX(162, FX_INK, object.drawX, object.drawY); ArrayPos0++; temp1--; object.drawX += 0x8; break	//2
			case 51; DrawSpriteScreenFX(163, FX_INK, object.drawX, object.drawY); ArrayPos0++; temp1--; object.drawX += 0x8; break	//3				
			case 64	//@	LINE SKIPPER
				object.drawY += 16
			
				temp0 -= 8
				object.drawX = temp0
				

				// Move to the next letter
				ArrayPos0++
				
				// And decrease the remaining letter count, as well
				temp1--
			break
			default
			// Notably, the space character (32) is skipped over here, as it shouldn't draw anything
			

			DrawSpriteScreenFX(Object.Frame, FX_INK, object.drawX, object.drawY)

			// Move to the next letter
			ArrayPos0++
			
			// And decrease the remaining letter count, as well
			temp1--
			
			// Each letter should be spaced 8 pixels apart
			object.drawX += 0x8
			break
		end switch
	loop
end function

//if being stupid was a job

event ObjectMain
	CallFunction(AutoMobile)
	switch object.state
		case DELTA_WAIT_0
			//Wait for action
			//Probably going to be called in UFO Object (Slenderman)
			bg.alpha = 0
			object.alpha = 0
			background.timer = 0
			// if inputpress.select == 1
			// 	Delta_Activate = 1
			// end if

			if Delta_Activate == 1
				playsfx(SfxName[BattleAlert], 0)
				object.state++
			end if
		break
		case DELTA_ALERT_1	
			//Set Positions!
			Player.Xpos = -32
			Slender.Xpos = screen.xsize
			object.charY = 150
			Options.AdjustY = 150
			object.timer++
			
			if object.timer == 60
				playsfx(SfxName[BattleStart], 0)
				object.state++	
				object.timer = 0
			end if
		break
		case DELTA_START_2
			//fade in things
			CallFunction(Delta_HUD)
			if bg.alpha < 255
				bg.alpha += 8
			else
				bg.alpha = 255
			end if
			

			if object.alpha < 255
				object.alpha += 8
			else
				object.alpha = 255
			end if	

			temp0 = screen.xcenter
			temp0 -= 135
			
			if player.xpos < temp0
				temp1 = 32
				temp1 >>= 2
				temp2++
				temp2 += temp1
				temp2 /= 4
				Player.Xpos+= temp2
			end if

			temp2 = screen.xcenter
			temp2 += 105
			if Slender.Xpos > temp2
				temp1 = -32
				temp1 >>= 2
				temp2++
				temp2 += temp1
				temp2 /= 28
				Slender.Xpos-= temp2
			endif

			if object.alpha == 255
				PlayMusic(7)	
				object.index = 1
				object.state++
			end if
		break
		case DELTA_BATTLEIDLE_3
			CallFunction(Delta_HUD)

			StopSfx(SfxName[SlenderTalk])
		
			// private alias 1  : DELTAOPT_FIGHT_PICKTARGET_1
			// private alias 2  : DELTAOPT_FIGHT_ATTACKING_2

			// private alias 3  : DELTAOPT_ACT_PICKTARGET_5
			// private alias 4  : DELTAOPT_ACT_CHOOSEACT_6

			// private alias 5  : DELTAOPT_ITEM_CHOOSEITEM_5
			// private alias 6  : DELTAOPT_ITEM_USEITEM

			// private alias 7  : DELTAOPT_SPARE_CHOOSETARGET_9
			// private alias 8  : DELTAOPT_SPARE_MERCYCHECK_8

			switch Options.State
			case DELTAOPT_CHOOSING_0
				Act.Selection = -1
				Item.Selection = -1
				if inputPress.right == 1
					PlaySfx(SfxName[Score Add], false)		
					if Options.Selected < 4
						Options.Selected++
					else
						Options.Selected = 0
					end if
				end if

				if inputPress.left == 1
					PlaySfx(SfxName[Score Add], false)		
					if Options.Selected > 0
						Options.Selected--
					else
						Options.Selected = 4
					end if
				end if	

				//draw the text
				GetTextInfo(temp0, 0, TEXTINFO_TEXTSIZE, Object.Index, 0)
				if object.charamount == temp0
		
				else
					object.charamount++
					PlaySfx(SfxName[Text], false)				
				end if	

				//Option States
				// private alias 0  : DELTAOPT_CHOOSING_0

				// private alias 1  : DELTAOPT_FIGHT_PICKTARGET_1
				// private alias 2  : DELTAOPT_FIGHT_ATTACKING_2

				// private alias 3  : DELTAOPT_ACT_PICKTARGET_5
				// private alias 4  : DELTAOPT_ACT_CHOOSEACT_6

				// private alias 5  : DELTAOPT_ITEM_CHOOSEITEM_5
				// private alias 6  : DELTAOPT_ITEM_USEITEM

				// private alias 7  : DELTAOPT_SPARE_CHOOSETARGET_9
				// private alias 8  : DELTAOPT_SPARE_MERCYCHECK_8

				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult
				if temp0 == 1
					playsfx(SfxName[Lamp Post], 0)
					switch Options.Selected
					case DELTAMENU_FIGHT_0
						object.index = 2
						object.charamount = 12
						Options.State = DELTAOPT_FIGHT_PICKTARGET_1
					break
					case DELTAMENU_ACT_1
						object.index = 2
						object.charamount = 12
						Options.State = DELTAOPT_ACT_PICKTARGET_5				
					break
					case DELTAMENU_ITEM_2
						object.index = 7
						switch Object.RingUsage
						case 0
							object.charamount = 32
						break
						case 1
							object.charamount = 24
						break						
						case 2
							object.charamount = 12
						break
						end switch
						Item.Selection = 0	
						Options.State = DELTAOPT_ITEM_CHOOSEITEM_7
					break	
					case DELTAMENU_SPARE_3
						object.index = 2
						object.charamount = 12
						Options.State = DELTAOPT_SPARE_CHOOSETARGET_9
					break		
					case DELTAMENU_DEFEND_4
						if Delta_TP < 100
							Delta_TP += 8
						else
							Delta_TP = 100
						end if


							Delta_Defending = 1
							Delta_YourTurn = 0
							object.rotation = 0
							object.scale = 0
							object.charamount = 0				
							object.AnimationTimer = 200
							object.animation = 4
							object.state = DELTA_DIALOGUE_4
						
					break		
					end switch
				end if
			break
			//they basically work the same, so why not just mix em
			case DELTAOPT_FIGHT_PICKTARGET_1
			case DELTAOPT_ACT_PICKTARGET_5
			case DELTAOPT_SPARE_CHOOSETARGET_9
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult
				if temp0 == 1
					playsfx(SfxName[Lamp Post], 0)
					switch Options.State
					case DELTAOPT_FIGHT_PICKTARGET_1
						object.index = -1
						object.charamount = 0
						Menu.AttackBar = screen.xsize
						Options.State = DELTAOPT_FIGHT_ATTACKING_2
					break
					case DELTAOPT_ACT_PICKTARGET_5
						if Object.Flirted == 0
							object.index = 3
						else
							object.index = 4
						end if
						object.charamount = -1				
						Act.Selection = 0	
						Options.State = DELTAOPT_ACT_CHOOSEACT_6
					break
					case DELTAOPT_SPARE_CHOOSETARGET_9
						if Delta_SlenderMercy >= 100	//spared
							object.index = -1
						else
							object.index = 10
						end if
						object.charamount = -1
						Object.TextProgress = 99
						Options.State = DELTAOPT_SPARE_MERCYCHECK_10
					break					
					end switch
				end if

				if inputpress.buttonB == 1
					if Object.LowText < 5
						switch Object.LowText
							case 0
								object.index = 1				
							break
							case 24	//out of ideasa ig lol
								object.index = 24
							break								
							default
								temp0 = 19
								temp0 += Object.LowText
								object.index = temp0
							break	
						end switch
					else
						object.index = 23
					end if
					object.charamount = 0
					Options.State = 0
				end if
				break
			//Here it comes!
			case DELTAOPT_FIGHT_ATTACKING_2
				Menu.AttackBar -= 3
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult
				if temp0 == 1
					Options.State = DELTAOPT_FIGHT_RESULTS_3
				end if
				
				//at least try man
				if Menu.AttackBar < 0
					Options.State = DELTAOPT_FIGHT_RESULTS_3
				end if
			break	
			case DELTAOPT_FIGHT_RESULTS_3
				//Right Limit
				Menu.AttackRadius = screen.xcenter
				Menu.AttackRadius -= 36

				if Menu.AttackBar > Menu.AttackRadius
					Menu.AttackDamage = 0	//miss
				else
					//Left Limit
					Menu.AttackLowerR = 0
					CheckLower(Menu.AttackBar, Menu.AttackRadius)
					temp0 = checkResult
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 |= checkResult					
					if temp0 == 1
						Menu.AttackDamage = 2	//dude
					end if

					Menu.AttackLowerR = screen.xcenter
					Menu.AttackLowerR -= 92	
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 = checkResult					
					if temp0 == 1
						playsfx(SfxName[Slash], 0)
						Menu.AttackDamage = 10	//dude
					end if

					Menu.AttackLowerR += 6	
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 = checkResult					
					if temp0 == 1
						playsfx(SfxName[Slash], 0)
						Menu.AttackDamage = 8	//dude
					end if

					Menu.AttackLowerR += 5	
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 = checkResult					
					if temp0 == 1
						playsfx(SfxName[Slash], 0)
						Menu.AttackDamage = 6	//dude
					end if

					Menu.AttackLowerR += 10	
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 = checkResult					
					if temp0 == 1
						playsfx(SfxName[Slash], 0)
						Menu.AttackDamage = 4	//dude
					end if

					Menu.AttackLowerR += 12	
					CheckGreater(Menu.AttackBar, Menu.AttackLowerR)
					temp0 = checkResult					
					if temp0 == 1
						playsfx(SfxName[Slash], 0)
						Menu.AttackDamage = 2	//dude
					end if


				end if
				

				if menu.AttackDamage > 0
					object.animationtimer = 5
				end if

				Options.State = DELTAOPT_FIGHT_EFFECTS_4
			break
			case DELTAOPT_FIGHT_EFFECTS_4
				Object.timer++

				if object.timer == 30
					if menu.AttackDamage > 0
						playsfx(SfxName[Attacked], 0)
						Delta_SlenderHP -= Menu.AttackDamage
						Slender.AnimTimer = 30
					end if
				end if

				if object.timer > 30
					if menu.AttackDamage > 0
						Object.TableTimer++
						GetTableValue(temp2, object.TableContainer, SlenderBounce)
						if Object.TableTimer >= 3
							object.TableContainer++
							if object.TableContainer > 14
								object.TableContainer = 14
							end if	
							Object.TableTimer = 0
						end if	

						Slender.XPos += temp2
					end if
				end if

				if Delta_SlenderHP > 0
					if object.timer > 100
						Delta_YourTurn = 0
						object.rotation = 0
						object.scale = 0
						object.charamount = 0
						object.animationtimer = 0
						object.state = DELTA_DIALOGUE_4
						object.TableContainer = 0
						Object.TableTimer = 0
						object.timer = 0
					end if
				else
					music.volume -= 2
					if music.volume == 0
						Delta_YourTurn = 0
						object.index = 110
						Object.TalkingChar = 1
						object.charamount = -1
						Object.TextProgress = 106						
						object.state = DELTA_BATTLEEND_8
						object.timer = 0
					end if
				end if
			break
			case DELTAOPT_ACT_CHOOSEACT_6
				if Object.Flirted == 0
					if inputpress.right == 1
						PlaySfx(SfxName[Score Add], false)		
						if act.Selection < 2
							Act.Selection++	
						else
							Act.Selection = 0
						end if
					end if

					if inputpress.left == 1
						PlaySfx(SfxName[Score Add], false)		
						if act.Selection > 0
							Act.Selection--	
						else
							Act.Selection = 2
						end if
					end if	

					if inputpress.up == 1
						PlaySfx(SfxName[Score Add], false)		
						Act.Selection = 0
					end if	

					if inputpress.down == 1
						PlaySfx(SfxName[Score Add], false)		
						Act.Selection = 2
					end if								
				else
					if inputpress.right == 1
						PlaySfx(SfxName[Score Add], false)		
						if act.Selection < 2
							Act.Selection = 2
						else
							Act.Selection = 0
						end if
					end if

					if inputpress.left == 1
						PlaySfx(SfxName[Score Add], false)		
						if act.Selection > 0
							Act.Selection = 0
						else
							Act.Selection = 2
						end if
					end if		

					if inputpress.up == 1
						PlaySfx(SfxName[Score Add], false)		
						Act.Selection = 0
					end if	

					if inputpress.down == 1
						PlaySfx(SfxName[Score Add], false)		
						Act.Selection = 2
					end if										
				end if	

				GetTextInfo(temp0, 0, TEXTINFO_TEXTSIZE, Object.Index, 0)
				object.charamount = temp0

				if inputpress.buttonB == 1
					Act.Selection = -1 
					if Object.LowText < 5
						switch Object.LowText
							case 0
								object.index = 1				
							break
							case 24	//out of ideasa ig lol
								object.index = 24
							break								
							default
								temp0 = 19
								temp0 += Object.LowText
								object.index = temp0
							break	
						end switch
					else
						object.index = 23
					end if
					object.charamount = 0
					Options.State = 0
				end if

				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult
				if temp0 == 1
					Delta_YourTurn = 0
					object.rotation = 0
					object.scale = 0
					object.charamount = 0				
					object.AnimationTimer = 200
					object.animation = 1
					object.state = DELTA_DIALOGUE_4
				end if


			break
			case DELTAOPT_ITEM_CHOOSEITEM_7
				switch Object.RingUsage
				case 0
					if inputpress.right == 1
						PlaySfx(SfxName[Score Add], false)		
						if Item.Selection < 2
							Item.Selection++	
						else
							Item.Selection = 0
						end if
					end if

					if inputpress.left == 1
						PlaySfx(SfxName[Score Add], false)		
						if Item.Selection > 0
							Item.Selection--	
						else
							Item.Selection = 2
						end if
					end if	

					if inputpress.up == 1
						PlaySfx(SfxName[Score Add], false)		
						Item.Selection = 0
					end if	

					if inputpress.down == 1
						PlaySfx(SfxName[Score Add], false)		
						Item.Selection = 2
					end if	
				break
				case 1
					if inputpress.right == 1
						PlaySfx(SfxName[Score Add], false)		
						if Item.Selection < 1
							Item.Selection++	
						else
							Item.Selection = 0
						end if
					end if

					if inputpress.left == 1
						PlaySfx(SfxName[Score Add], false)		
						if Item.Selection > 0
							Item.Selection--	
						else
							Item.Selection = 1
						end if
					end if	
				break		
				case 2
					Item.Selection = 0
				break		
				end switch
			
				if inputpress.buttonB == 1
					if Object.LowText < 5
						switch Object.LowText
							case 0
								object.index = 1				
							break
							case 24	//out of ideasa ig lol
								object.index = 24
							break								
							default
								temp0 = 19
								temp0 += Object.LowText
								object.index = temp0
							break	
						end switch
					else
						object.index = 23
					end if
					Item.Selection = -1
					object.charamount = 0
					Options.State = 0
				end if

				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					Delta_YourTurn = 0
					object.rotation = 0
					object.scale = 0
					object.charamount = 0				
					object.AnimationTimer = 200
					object.animation = 3
					object.state = DELTA_DIALOGUE_4
				end if


			break		
			case DELTAOPT_SPARE_MERCYCHECK_10
				if Delta_SlenderMercy < 100	//Not 100
					//draw the text
					GetTextInfo(temp0, 0, TEXTINFO_TEXTSIZE, Object.Index, 0)
					if object.charamount == temp0
			
					else
						object.charamount++
						PlaySfx(SfxName[Text], false)				
					end if	

					CheckEqual(inputpress.start, 1)
					temp0 = checkResult
					CheckEqual(inputpress.buttonA, 1)
					temp0 |= checkResult				
					if temp0 == 1
						Delta_SlenderMercy += 2
						Delta_YourTurn = 0
						object.rotation = 0
						object.scale = 0
						object.charamount = 0				
						object.state = DELTA_DIALOGUE_4
					end if
				else	//spared
					music.volume -= 2
					if music.volume == 0
						SlenderSpared = 1
						Delta_YourTurn = 0
						object.index = 99
						Object.TalkingChar = 1
						object.charamount = 0		
						object.state = DELTA_BATTLEEND_8
					end if
				end if
			break	
			end switch
	break
	case DELTA_DIALOGUE_4
		CallFunction(Delta_HUD)
		Options.State = -1

			CheckGreater(act.selection, -1)
			temp1 = checkResult
			CheckGreater(item.selection, -1)
			temp1 |= checkResult			
			if temp1 == 1
				if act.Selection > -1
					switch act.Selection
					case 0	//Check
						Object.index = 5
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = 0
							Act.Selection = -1
							object.AnimationTimer = 0
						//	Text.Proceed = 1
						end if	
					break
					case 1	//Flirt
						music.volume = 0
						Object.index = -1
						object.timer++
						if object.timer == 400
							Object.Flirted = 1
							object.charamount = 0
							Act.Selection = -1
							object.AnimationTimer = 0
							music.volume = 100
							object.timer = 0
						end if
					break
					case 2	//Collect
						Object.index = 6
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							Delta_BecomeGreen = 1
							object.charamount = 0
							Act.Selection = -1
							object.AnimationTimer = 0
						//	Text.Proceed = 1
						end if	
					break		
					end switch
				end if

				if Item.Selection > -1
					switch Item.Selection
					case 0	//Pages
						Object.index = 8
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = 0
							Item.Selection = -1
							object.AnimationTimer = 0
						//	Text.Proceed = 1
						end if	
					break
					case 1	//Use Rings
					case 2
						Object.index = 9
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1

							if ringPan == 0
								PlaySfx(SfxName[Ring L], 0)
								SetSfxAttributes(SfxName[Ring L], -1, -100)
								ringPan = 1
							else
								PlaySfx(SfxName[Ring R], 0)
								SetSfxAttributes(SfxName[Ring R], -1, 100)
								ringPan = 0
							end if

							Delta_HP += 20

							if Delta_HP > 90
								Delta_HP = 90
							end if

							Object.RingUsage++
							object.charamount = 0
							Item.Selection = -1
							object.AnimationTimer = 0
						end if	
					break			
					end switch
				end if
			else
				switch Object.TextProgress
					case 0	//Whats This even about
						Object.TalkingChar = 0	//You
						Object.index = 50
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
						end if
					break
					case 1	//Sorry got tired
						Object.TalkingChar = 1	//Slender
						Object.index = 51
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = 0
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break
					case 2	//Im Slenderss
						Object.TalkingChar = 1	//Slender
						Object.index = 52
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = 0
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break	
					case 3	//My forest!
						Object.TalkingChar = 1	//Slender
						Object.index = 53
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = 0
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break	
					case 4	//Not nice
						Object.TalkingChar = 1	//Slender
						Object.index = 54

						if saved.language == 3
							Object.BoxLength = 1
						end if

						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
						end if				
					break			
					case 5	//you.
						Object.BoxLength = 0
						Object.TalkingChar = 0	//Slender
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break			
					case 6	//like the pages?
						Object.TalkingChar = 1	//Slender
						Object.index = 56
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break	
					case 7	//couldnt read em
						Object.TalkingChar = 0	//Slender
						Object.index = 57
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break		
					case 8	//couldnt read em
						Object.TalkingChar = 1	//Slender
						Object.index = 58
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
						//	Text.Proceed = 1
						end if				
					break				
					case 9	//club
						Object.TalkingChar = 1	//Slender
						Object.index = 59
						if saved.language == 2
							Object.BoxLength = 1
						end if
						CheckEqual(inputpress.start, 1)
						temp0 = checkResult
						CheckEqual(inputpress.buttonA, 1)
						temp0 |= checkResult				
						if temp0 == 1
							object.charamount = -1
							Object.TextProgress++
							Object.index++
							Text.Proceed = 1
						end if				
					break																					
					default
						Object.TalkingChar = -1
						object.charamount = 0
						Text.Proceed = 1
					break										
				end switch
			end if

		
			//draw the text
			GetTextInfo(temp0, 0, TEXTINFO_TEXTSIZE, Object.Index, 0)
			if object.charamount == temp0

			else
				object.charamount++
				if Object.TalkingChar == 0
					StopSfx(SfxName[SlenderTalk])
					PlaySfx(SfxName[Text], false)		
				else

					CheckGreater(act.selection, -1)
					temp1 = checkResult
					CheckGreater(item.selection, -1)
					temp1 |= checkResult			
					if temp1 == 1
						StopSfx(SfxName[SlenderTalk])
						PlaySfx(SfxName[Text], false)
					else
						PlaySfx(SfxName[SlenderTalk], false)		
					end if
				end if		
			end if		
	

		if Text.Proceed == 1
			object.animationtimer = 0
			StopSfx(SfxName[Text])	
			StopSfx(SfxName[SlenderTalk])
			object.state++
			Text.Proceed = 0

			//yes im so serious
			temp1 = screen.xcenter
			temp1 *= 0x100
			temp2 = Screen.ycenter
			temp2 *= 0x100
			
			CreateTempObject(TypeName[Delta Bounds], 0, temp1, temp2)
			object[tempObjectPos].drawOrder = 6		

			// // State aliases
			// private alias 0  : DELTAATTACKS_PROJECTILE_0
			// private alias 1  : DELTAATTACKS_PROJECTILE_MERCY_1
			// private alias 2  : DELTAATTACKS_THUNDERALERT_2
			// private alias 3  : DELTAATTACKS_FASTTHUNDER_3
			// private alias 4  : DELTAATTACKS_TREE_UP_4
			// private alias 5  : DELTAATTACKS_TREE_DOWN_5
			// private alias 6  : DELTAATTACKS_TREE_RIGHT_6
			// private alias 7  : DELTAATTACKS_TREE_LEFT_7

			if Object.AttackOrder < 6
				switch Object.AttackOrder
					case 0
					case 1
						Attack.Property = 0
						Delta_AttackHardMode = 0
					break
					case 2
						Attack.Property = 2
						Delta_AttackHardMode = 0
					break				
					case 3
						Attack.Property = 4
						Delta_AttackHardMode = 0
					break		
					case 4
						Attack.Property = 5
						Delta_AttackHardMode = 0
					break		
					case 5
						Attack.Property = 6
						Delta_AttackHardMode = 0
					break		
					default
						rand(temp4, 6)
						rand(temp3, 10)
						Attack.Property = temp4
						if temp3 >= 5
							Delta_AttackHardMode = 1
						else
							Delta_AttackHardMode = 0
						end if
					break												
				end switch
			else
				rand(temp4, 6)
				rand(temp3, 10)

				if temp4 == 3		
					temp4 = 6
				end if

				Attack.Property = temp4
				if temp3 >= 5
					Delta_AttackHardMode = 1
				else
					Delta_AttackHardMode = 0
				end if
			end if

			temp1 = screen.xcenter
			temp1 *= 0x19000
			temp2 = Screen.ycenter
			temp2 *= 0x10000
			
			CreateTempObject(TypeName[Delta Attacks], Attack.Property, temp1, temp2)
			object[tempObjectPos].drawOrder = 6		
			switch object[tempObjectPos].propertyValue
				case 4
				case 5
				case 6
				case 7
					object[tempObjectPos].value3 = 75	
				break
			end switch		



			Object.AttackTimer = 800

			temp0 = Slender.xpos
			temp0 *= 0x20000
			CreateTempObject(TypeName[Delta Soul], 0, temp0, Screen.ycenter)
			object[tempObjectPos].drawOrder = 6		
			object.timer = 0	
		end if

	break
	case DELTA_ATTACKSTART_5
		CallFunction(Delta_HUD)
		Options.State = -1
		if object.scale == 512
			object.state = DELTA_ATTACKING_6
		end if
	break
	case DELTA_ATTACKING_6
		CallFunction(Delta_HUD)

		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)	
			//Top
		//	BoxCollisionTest(C_BOX, object.entityPos, 175, 66, 173, 141, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			//Bottom
			temp0 = screen.xcenter
			temp0 -= 38
			temp1 = screen.xcenter
			temp1 += 38			
			BoxCollisionTest(C_BOX, object.entityPos, temp0, 139, temp1, 141, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			BoxCollisionTest(C_TOUCH, object.entityPos, temp0, 66, temp1, 68, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			if checkResult == 1
				if inputdown.down == 1

				else
					object[currentPlayer].yvel = 0
				end if
			end if			


			//Left
			temp0 = screen.xcenter
			temp0 -= 38
			temp1 = screen.xcenter
			temp1 -= 36	
			BoxCollisionTest(C_TOUCH, object.entityPos, temp0, 66, temp1, 141, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			if checkResult == 1
				if inputdown.right == 1

				else
					object[currentPlayer].speed = 0
					object[currentPlayer].xvel = 0
				end if
			end if


			
			//Right
			temp0 = screen.xcenter
			temp0 += 35
			temp1 = screen.xcenter
			temp1 += 33	
			BoxCollisionTest(C_TOUCH, object.entityPos, temp0, 66, temp1, 141, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			if checkResult == 1
				if inputdown.left == 1

				else
					object[currentPlayer].speed = 0
					object[currentPlayer].xvel = 0
				end if
			end if
			
		next

		 if Object.AttackTimer > 0
		 	Object.AttackTimer--
		 end if

		if Object.AttackTimer <= 0
			object[tempObjectPos].type = TypeName[Blank Object]
			ResetObjectEntity(currentPlayer, TypeName[Blank Object], 0, object.xpos, object.ypos)
			object.state = DELTA_ATTACKEND_7
			object.rotation = 512
			object.scale = 512
		end if
	break
	case DELTA_ATTACKEND_7
		CallFunction(Delta_HUD)
		Options.State = 0

		
	
		object.rotation -= 16
	
		object.scale -= 16

		if object.scale == 0
			Object.TalkingChar = -1
			Object.AttackOrder++
			Delta_YourTurn = 1
			Delta_Defending = 0
			if Object.LowText < 5
				Object.LowText++
				switch Object.LowText
					case 0
						object.index = 1				
					break
					case 24	//out of ideasa ig lol
						object.index = 24
					break								
					default
						temp0 = 19
						temp0 += Object.LowText
						object.index = temp0
					break	
				end switch
			else
				object.index = 23
			end if
			Delta_BecomeGreen = 0
			Object.AnimationTimer = 0
			object.state = DELTA_BATTLEIDLE_3
		end if
	break
	case DELTA_BATTLEEND_8
		CallFunction(Delta_HUD)

		if Delta_SlenderMercy >= 100
			switch Object.TextProgress
			case 99	//...
				Object.TalkingChar = 1
				Object.index = 99
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = -1
					Object.TextProgress++
					Object.index++
				end if
			break
			case 100	//sparing me?
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break
			case 101	//uh yea
				Object.TalkingChar = 0	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break			
			case 102	//...
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break			
			case 103	//return favor
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break				
			case 104	//mercy too
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break		
			case 105	//end battle
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
					PlaySfx(SfxName[sans], 0)
					Text.Proceed = 1
				end if				
			break						
			end switch
		end if

		//ya killed him...
		if Delta_SlenderHP <= 0
			switch Object.TextProgress
			case 106	//ok jeez
				Object.TalkingChar = 1
				Object.index = 110
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = -1
					Object.TextProgress++
					Object.index++
				end if
			break
			case 107	//hurry up
				Object.TalkingChar = 0	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
				//	Text.Proceed = 1
				end if				
			break
			case 108	//alright fine
				Object.TalkingChar = 1	//Slender
				CheckEqual(inputpress.start, 1)
				temp0 = checkResult
				CheckEqual(inputpress.buttonA, 1)
				temp0 |= checkResult				
				if temp0 == 1
					object.charamount = 0
					Object.TextProgress++
					Object.index++
					PlaySfx(SfxName[sans], 0)
					Text.Proceed = 1
				end if				
			break			
			end switch
		end if

		if Text.Proceed == 0
			//draw the text
			GetTextInfo(temp0, 0, TEXTINFO_TEXTSIZE, Object.Index, 0)
			if object.charamount == temp0

			else
				object.charamount++
				if Object.TalkingChar == 0
					StopSfx(SfxName[SlenderTalk])
					PlaySfx(SfxName[Text], false)		
				else
					CheckGreater(act.selection, -1)
					temp1 = checkResult
					CheckGreater(item.selection, -1)
					temp1 |= checkResult			
					if temp1 == 1
						StopSfx(SfxName[SlenderTalk])
						PlaySfx(SfxName[Text], false)
					else
						PlaySfx(SfxName[SlenderTalk], false)		
					end if
				end if			
			end if	
		else	//done
			object.timer++
			if object.timer == 100
				Delta_Activate = 0	//its over
				PlaySfx(SfxName[sans], 0)
				SSonic.PauseState = 1
				object.type = TypeName[Blank Object]
			end if
		end if
	break
	case DELTA_DIED_90
		if object[currentPlayer].outofbounds == 1
			PlayMusic(8)
			object.alpha = 0
			object.state = DELTA_DIED_FADEIN_91
		end if
	break
	case DELTA_DIED_FADEIN_91
		if object.alpha < 255
			object.alpha += 8
		else
			object.alpha = 255
		end if

		object.timer++
		if object.timer == 400
			PlayerDied = 1
			PlaySfx(SfxName[NULL], 0)
			object.state++
			object.timer = 0
		end if
	break
	case DELTA_DIED_GAMEOVER_92
		//youre already gonna have have a checkpoint at this point
		//so it doesntmatter kinda
		object.timer++
		if object.timer >= 440
			if Final.Fade >= 256
				stage.activeList = BONUS_STAGE
				stage.listPos = 11
				LoadStage()			
				//restore later
				//CallNativeFunction(ExitGame)
				Final.Fade = 256	
			end if	
		end if

		if object.timer >= 600
			Final.Fade += 16
		end if

		SetClassicFade(0, 0, 0, Final.Fade)
	break
end switch

	if Delta_SlenderMercy > 100
		Delta_SlenderMercy = 100
	end if


	if object.state < DELTA_DIED_90
		if Delta_HP <= 0
			StopMusic()
			object.timer = 0
			object.state = DELTA_DIED_90
		end if
	end if

	ProcessObjectControl()	
end event

event ObjectDraw
	if PlayerDied == 0
	//	DrawRect(0, 0, screen.xsize, screen.ysize, 0x00, 0x00, 0x00, 160)
		if Delta_Activate == 1
			CallFunction(Delta_BG)
		end if
	end if

	switch object.state
		case DELTA_START_2
			//BG
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)


			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)


			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			DrawSpriteScreenXY(47, Player.Xpos, screen.ycenter)


			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)

		break
		case DELTA_BATTLEIDLE_3
			//BG
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)


			object.inkEffect = INK_ALPHA

			ArrayPos0 = 0	//starting letter
				
			object.drawY = 205

			temp3 = screen.xcenter
			temp3 -= 130
			object.drawX = temp3
			

			CallFunction(Delta_TextDrawing)

			switch options.State
			case DELTAOPT_FIGHT_ATTACKING_2	//prep attack
				DrawSpriteScreenXY(187, Player.Xpos, screen.ycenter)
			break
			case DELTAOPT_FIGHT_RESULTS_3	//prep attack
			case DELTAOPT_FIGHT_EFFECTS_4
				if Menu.AttackDamage > 0	//did damage

					if object.animationtimer > 0
						object.animationtimer--
					else
						object.animationtimer = 0
					end if

					if object.animationtimer > 0
						DrawSpriteScreenXY(188, Player.Xpos, screen.ycenter)	//swingin
					else
						DrawSpriteScreenXY(189, Player.Xpos, screen.ycenter)	//swung!
					end if
				else	//you suck man
					DrawSpriteScreenXY(187, Player.Xpos, screen.ycenter)
				end if
			break			
			default
				DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
			break
			end switch

			if Slender.AnimTimer > 0
				Slender.AnimTimer--
			end if

			switch options.State
			case DELTAOPT_FIGHT_EFFECTS_4
				if Slender.AnimTimer > 0
					if menu.AttackDamage > 0
						DrawSpriteScreenXY(55, Slender.Xpos, screen.ycenter)
					else
						DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)						
					end if
				else
					DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)
				end if
			break
			default
				DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)
			break
			end switch
			

			switch Options.State
			case DELTAOPT_FIGHT_PICKTARGET_1
			case DELTAOPT_ACT_PICKTARGET_5
			case DELTAOPT_SPARE_CHOOSETARGET_9
				//name handled in main

				//HP

				//Soul next to Slendermans Name
				temp3 = screen.xcenter
				temp3 -= 150		
				temp4 = object.drawY
				temp4 -= 8
				DrawSpriteScreenXY(75, temp3, temp4)
				temp3 = screen.xcenter
				temp3 += 30
				//Backing Red Bar
				DrawRect(temp3, temp4, 50, 8, color4, 0, 0, object.alpha)
				//Green Actual HP Display
				temp2 = 50	
				temp2 *= Delta_SlenderHP
				temp2 /= 100
				temp2 %= 100
				DrawRect(temp3, temp4, temp2, 8, 0, color7, 0, object.alpha)
				DrawSpriteScreenXY(76, temp3, temp4)
				temp4 += 44
				if Delta_SlenderHP > 0
					DrawNumbers(60, temp3, temp4, Delta_SlenderHP, 3, 4, 0)
				else
					DrawNumbers(60, temp3, temp4, 0, 3, 4, 0)
				end if

				temp3 = screen.xcenter
				temp3 += 90
				temp4 = object.drawY
				temp4 -= 8				
				//Backing Red Bar
				DrawRect(temp3, temp4, 50, 8, color4, 0, 0, object.alpha)
				//Yellow Actual Mercy
				temp2 = 50	
				temp2 *= Delta_SlenderMercy
				temp2 /= 100
				temp2 %= 100
				if Delta_SlenderMercy < 100
					DrawRect(temp3, temp4, temp2, 8, color7, color7, 0, object.alpha)
				else
					DrawRect(temp3, temp4, 50, 8, color7, color7, 0, object.alpha)
				end if
				DrawSpriteScreenXY(77, temp3, temp4)
				temp4 += 44
				if Delta_SlenderMercy < 100
					DrawNumbers(78, temp3, temp4, Delta_SlenderMercy, 3, 4, 0)
				else
					DrawNumbers(78, temp3, temp4, 100, 3, 4, 0)
				end if



			break
			case DELTAOPT_FIGHT_ATTACKING_2
			case DELTAOPT_FIGHT_RESULTS_3
			case DELTAOPT_FIGHT_EFFECTS_4
				//Icon, Press, Attack bar
				//Head Icon
				temp3 = screen.xcenter
				temp3 -= 140		
				temp4 = object.drawY
				temp4 -= 9
				switch stage.playerlistpos
				case 0
					DrawSpriteScreenXY(88, temp3, temp4)
				break
				case 1
					DrawSpriteScreenXY(89, temp3, temp4)
				break
				case 2
					DrawSpriteScreenXY(90, temp3, temp4)
				break				
				case 5
					DrawSpriteScreenXY(91, temp3, temp4)
				break
				end switch				

				//line
				temp4 += 8
				DrawRect(temp3, temp4, 96, 1, 0, 0, color2, object.alpha)
				//Press A
				temp3 += 20
				temp4 -= 4
				DrawSpriteScreenXY(92, temp3, temp4)
				//Attack bar
				temp3 += 30
				temp4 -= 4
				switch stage.playerlistpos
					case 0
						DrawSpriteScreenXY(93, temp3, temp4)
					break
					case 1
						DrawSpriteScreenXY(181, temp3, temp4)
					break
					case 2
						DrawSpriteScreenXY(182, temp3, temp4)
					break					
					case 5
						DrawSpriteScreenXY(183, temp3, temp4)
					break					
				end switch


				DrawSpriteScreenXY(94, Menu.AttackBar, temp4)

				// DrawNumbers(34, 32, 32, Menu.AttackBar, 3, 8, 0)
				// DrawNumbers(34, 32, 64, Menu.AttackRadius, 3, 8, 0)
				// DrawNumbers(34, 32, 96, Menu.AttackLowerR, 3, 8, 0)

				if options.state == DELTAOPT_FIGHT_EFFECTS_4
					if object.timer > 29
						temp0 = Slender.xpos
						temp0 -= 8
						Menu.DmgNumberY = 96
						

						Object.AltTimer++
						GetTableValue(temp2, object.TableContainer, NumberBounce)
						if Object.AltTimer >= 3
							object.TableContainer++
							if object.TableContainer > 14
								object.TableContainer = 14
							end if	
							Object.AltTimer = 0
						end if	

						Menu.DmgNumberY -= temp2
						
						DrawNumbers(95, temp0, Menu.DmgNumberY, Menu.AttackDamage, 3, 10, 0)
					end if
				end if
			break
			case DELTAOPT_ACT_CHOOSEACT_6
				switch Act.Selection
					case 0
						temp3 = screen.xcenter
						temp3 -= 150		
						DrawSpriteScreenXY(75, temp3, 197)
					break
					case 1
						temp3 = screen.xcenter
						temp3 -= 20		
						DrawSpriteScreenXY(75, temp3, 197)
					break		
					case 2
						temp3 = screen.xcenter
						temp3 -= 150		
						DrawSpriteScreenXY(75, temp3, 213)
					break								
				end switch
			break
			case DELTAOPT_ITEM_CHOOSEITEM_7
				switch Item.Selection
					case 0
						temp3 = screen.xcenter
						temp3 -= 150		
						DrawSpriteScreenXY(75, temp3, 197)
					break
					case 1
						temp3 = screen.xcenter
						temp3 -= 20		
						DrawSpriteScreenXY(75, temp3, 197)
					break		
					case 2
						temp3 = screen.xcenter
						temp3 -= 150		
						DrawSpriteScreenXY(75, temp3, 213)
					break								
				end switch
			break
			case DELTAOPT_SPARE_MERCYCHECK_10


			break
			end switch
		break
		case DELTA_DIALOGUE_4
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			if object.AnimationTimer > 0
				object.AnimationTimer--
				switch object.animation	//Idle
				case 0
					DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
				break
				case 1	//Act
					DrawSpriteScreenXY(49, Player.Xpos, screen.ycenter)
				break		
				case 2	//Hurt
					DrawSpriteScreenXY(53, Player.Xpos, screen.ycenter)
				break			
				case 3	//Ittem
					DrawSpriteScreenXY(50, Player.Xpos, screen.ycenter)
				break		
				case 4	//Defend
					DrawSpriteScreenXY(52, Player.Xpos, screen.ycenter)
				break		
				end switch
			else
				object.AnimationTimer = 0
				DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
			end if
			

			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)

			object.inkEffect = INK_ALPHA

			ArrayPos0 = 0	//starting letter

			CheckGreater(act.Selection, -1)
			temp1 = checkResult
			CheckGreater(item.Selection, -1)
			temp1 |= checkResult			
			if temp1 == 1
				object.drawY = 205

				temp3 = screen.xcenter
				temp3 -= 130
				object.drawX = temp3
				

				CallFunction(Delta_TextDrawing)
			else
			
				switch Object.TalkingChar
				case 0
					temp1 = Player.Xpos
					temp1 += 80
					temp2 = screen.ycenter
					temp2 += 12
					DrawSpriteScreenXY(106, temp1, temp2)

					temp2 -= 36
					object.drawY = temp2

					temp1 -= 22
					object.drawX = temp1
				break
				case 1
					temp1 = Slender.Xpos
					temp1 -= 55
					temp2 = screen.ycenter
					temp2 += 0
					if Object.BoxLength == 0
						DrawSpriteScreenXY(192, temp1, temp2)
					else
						DrawSpriteScreenXY(202, temp1, temp2)
					end if

					temp2 -= 36
					object.drawY = temp2

					temp1 -= 34
					object.drawX = temp1
				break
				default

				break
				end switch


				CallFunction(Delta_TalkingText)			
			end if

			if act.Selection == 1
				DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)
				DrawSpriteScreenXY(170, screen.xcenter, screen.ycenter)
			end if

		break
		case DELTA_ATTACKSTART_5
			//BG
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			if Delta_Defending == 0
				DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)	//normal
			else
				DrawSpriteScreenXY(52, Player.Xpos, screen.ycenter)	//defend anim
			end if

			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)
		

			temp0 = screen.xcenter
			temp1 = screen.ycenter
			temp1 -= 16
			DrawSpriteScreenFX(105, FX_ROTOZOOM, temp0, temp1)

			if object.rotation < 512
				object.rotation += 8
			else
				object.rotation = 512
			end if


			if object.scale < 512
				object.scale += 8
			else
				object.scale = 512
			end if
			
		break
		case DELTA_ATTACKING_6
			//BG
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			

			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)
		

			temp0 = screen.xcenter
			temp1 = screen.ycenter
			temp1 -= 16
			DrawSpriteScreenXY(105, temp0, temp1)

			if Delta_Defending == 1
				DrawSpriteScreenXY(52, Player.Xpos, screen.ycenter)
			else
				if object.AnimationTimer > 0
					object.AnimationTimer--
					switch object.animation	//Idle
					case 0
						DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
					break
					case 2	//Act
						DrawSpriteScreenXY(53, Player.Xpos, screen.ycenter)
					break				
					end switch
				else
					DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
				end if
			end if

			if Delta_ShowMercy == 1

				temp0 = Slender.xpos
				temp0 -= 8
				Mercy.NumberY = 96
				

				Object.AltTimer++
				GetTableValue(temp2, object.TableContainer, NumberBounce)
				if Object.AltTimer >= 3
					object.TableContainer++
					if object.TableContainer > 14
						object.TableContainer = 14
					end if	
					Object.AltTimer = 0
				end if	

				Mercy.NumberY -= temp2
				
				DrawNumbers(171, temp0, Mercy.NumberY, Delta_SlenderMercy, 3, 10, 0)

			end if
		
			
		break	
		case DELTA_ATTACKEND_7
			Delta_ShowMercy = 0
			//BG
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)

			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)
		

			temp0 = screen.xcenter
			temp1 = screen.ycenter
			temp1 -= 16
			DrawSpriteScreenFX(105, FX_ROTOZOOM, temp0, temp1)


		break		
		case DELTA_BATTLEEND_8
			DrawRect(0, HUD.Ypos, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			//HUD
			CallFunction(Delta_PlayerHUD)

			//OVERLAY

			temp0 = HUD.Ypos
			temp0 += 18
			DrawRect(0, temp0, screen.xsize, screen.ysize, 0, 0, 0, object.alpha)

			

			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)
			HUD.Ypos += 17
			DrawRect(0, HUD.Ypos, screen.xsize, 1, color2, color1, color2, object.alpha)

			object.AnimationTimer = 0
			DrawSpriteScreenXY(46, Player.Xpos, screen.ycenter)
			
			

			DrawSpriteScreenXY(54, Slender.Xpos, screen.ycenter)

			object.inkEffect = INK_ALPHA

			ArrayPos0 = 0	//starting letter


			switch Object.TalkingChar
			case 0
				temp1 = Player.Xpos
				temp1 += 80
				temp2 = screen.ycenter
				temp2 += 12
				DrawSpriteScreenXY(106, temp1, temp2)

				temp2 -= 36
				object.drawY = temp2

				temp1 -= 22
				object.drawX = temp1
			break
			case 1
				temp1 = Slender.Xpos
				temp1 -= 65
				temp2 = screen.ycenter
				temp2 += 0
				DrawSpriteScreenXY(192, temp1, temp2)

				temp2 -= 36
				object.drawY = temp2

				temp1 -= 34
				object.drawX = temp1
			break
			default

			break
			end switch


			CallFunction(Delta_TalkingText)			
			

			if act.Selection == 1
				DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)
				DrawSpriteScreenXY(170, screen.xcenter, screen.ycenter)
			end if

			if Text.Proceed == 1
				DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)
			end if

		break			
		case DELTA_DIED_90
			DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)
		break	
		case DELTA_DIED_FADEIN_91
			DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)

			DrawSpriteScreenFX(184, FX_INK, screen.xcenter, screen.ycenter)
		break			
	end switch
	
	if saved.mobile == 1
		if Delta_Activate == 1
			Callfunction(Delta_TouchDraw)
		end if
	end if

	// temp5 = act.Selection
	// abs(temp5)
	//DrawNumbers(34, 32, 32, Object.AttackOrder, 3, 8, 0)
	// DrawNumbers(34, 32, 64, Object.State, 3, 8, 0)

end event

event ObjectStartup

	// case 0 //English
	// 	LoadTextFile(1, "Data/Game/MenuTextEN.txt")
	// 	break
	// case 1 //Portuguese
	// 	LoadTextFile(1, "Data/Game/MenuTextPR.txt")
	// 	break
	// case 2 //Spanish
	// 	LoadTextFile(1, "Data/Game/MenuTextSP.txt")
	// 	break
	// case 3 //French
	// 	LoadTextFile(1, "Data/Game/MenuTextFR.txt")
	// 	break
	// case 4 //German
	// 	LoadTextFile(1, "Data/Game/MenuTextDE.txt")
	// 	break

	LoadSpriteSheet("3D_Test/DeltaSheet.gif")

	switch saved.language
		case 0
			LoadTextFile(0, "Data/Game/SlenderBattle.txt")
		break
		case 1	//PTBR
			LoadTextFile(0, "Data/Game/Portuguese/SlenderBattle.txt")
		break
		case 2
			LoadTextFile(0, "Data/Game/Spanish/SlenderBattle.txt")
		break
		case 3
			LoadTextFile(0, "Data/Game/French/SlenderBattleFR.txt")
		break		
	end switch

	if saved.SlenderOST == 0
		SetMusicTrack("SlenderBattle.ogg", 7, 1)
	else
		SetMusicTrack("SlendyBattleM.ogg", 7, 1)
	end if
	SetMusicTrack("DeltaDie.ogg", 8, 1)
	SpriteFrame(0, 0, 0, 0, 0, 0)	//0 the bar


	// 0-33
	temp5 = 1
	while temp5 < 21
		temp6 = 256
		while temp6 < 354
			SpriteFrame(-3, -6, 8, 7, temp6, temp5)
			temp6 += 9
		loop
		temp5 += 7
	loop	

	//34-43		0-9		Big Numbers
	SpriteFrame(0, 0, 8, 13, 467, 484)
	SpriteFrame(0, 0, 8, 13, 476, 484)
	SpriteFrame(0, 0, 8, 13, 485, 484)
	SpriteFrame(0, 0, 8, 13, 494, 484)
	SpriteFrame(0, 0, 8, 13, 503, 484)
	SpriteFrame(0, 0, 8, 13, 467, 498)
	SpriteFrame(0, 0, 8, 13, 476, 498)
	SpriteFrame(0, 0, 8, 13, 485, 498)
	SpriteFrame(0, 0, 8, 13, 494, 498)
	SpriteFrame(0, 0, 8, 13, 503, 498)

	//44 BG Front
	SpriteFrame(0, 0, 64, 64, 1, 234)
	//45 BG Back
	SpriteFrame(0, 0, 64, 64, 1, 169)	
	//Battle Player	- 
	switch stage.playerlistpos
	case 0
		SpriteFrame(0, -18, 30, 38, 1, 10)	//46 Idle
		SpriteFrame(-6, -18, 34, 36, 32, 12)	//47 Battle Enter
		SpriteFrame(0, -18, 30, 38, 1, 10)	//48 Fight
		SpriteFrame(0, -20, 34, 40, 97, 8)	//49 Act
		SpriteFrame(2, -19, 29, 39, 175, 9)	//50 Item
		SpriteFrame(0, -20, 34, 40, 97, 8)	//51 Mercy
		SpriteFrame(2, -19, 29, 39, 67, 9)	//52 Defend	
		SpriteFrame(0, -18, 40, 38, 134, 10)	//53 Hurt	
	break
	case 1
		SpriteFrame(0, -11, 32, 31, 78, 480)	//46 Idle
		SpriteFrame(0, -9, 32, 29, 111, 482)	//47 Battle Enter
		SpriteFrame(0, -11, 32, 31, 78, 480)	//48 Fight
		SpriteFrame(-1, -12, 39, 32, 183, 479)	//49 Act
		SpriteFrame(2, -19, 31, 39, 256, 472)	//50 Item
		SpriteFrame(-1, -12, 39, 32, 183, 479)	//51 Mercy
		SpriteFrame(-2, -3, 38, 23, 144, 488)	//52 Defend	
		SpriteFrame(2, -18, 32, 32, 223, 479)	//53 Hurt	
	break	
	case 2
		SpriteFrame(0, -20, 27, 40, 78, 439)	//46 Idle
		SpriteFrame(-4, -20, 41, 36, 106, 443)	//47 Battle Enter
		SpriteFrame(0, -20, 27, 40, 78, 439)	//48 Fight
		SpriteFrame(2, -19, 32, 39, 186, 439) //49 Act
		SpriteFrame(-4, -25, 38, 45, 256, 426)	//50 Item
		SpriteFrame(2, -19, 32, 39, 186, 439)	//51 Mercy
		SpriteFrame(0, -20, 27, 40, 148, 439)	//52 Defend	
		SpriteFrame(2, -18, 36, 38, 219, 440)	//53 Hurt	
	break		
	case 5
		SpriteFrame(0, -16, 23, 36, 78, 402)	//46 Idle
		SpriteFrame(0, -14, 26, 32, 102, 406)	//47 Battle Enter
		SpriteFrame(0, -16, 23, 36, 78, 402)	//48 Fight
		SpriteFrame(2, -15, 22, 35, 156, 403)	//49 Act
		SpriteFrame(2, -20, 27, 40, 206, 398)	//50 Item
		SpriteFrame(0, -20, 34, 40, 97, 8)	//51 Mercy
		SpriteFrame(0, -11, 26, 31, 129, 407)	//52 Defend	
		SpriteFrame(0, -12, 26, 29, 179, 409)	//53 Hurt	
	break	
	end switch

	//Slenderman!!!
	SpriteFrame(0, -43, 35, 63, 67, 100)	//54 Idle
	SpriteFrame(0, -41, 40, 62, 103, 101)	//55 Hurt

	SpriteFrame(-50, -44, 111, 34, 256, 32)	//56 Sonic HUD
	SpriteFrame(-50, -44, 111, 34, 400, 1)	//57 Tails HUD
	SpriteFrame(-50, -44, 111, 34, 400, 36)	//58 Knuckles HUD
	SpriteFrame(-50, -44, 111, 34, 400, 71)	//59 Amy HUD

	//delta numbers
	//60-69
	temp6 = 256
	while temp6 < 295
		SpriteFrame(26, -42, 3, 5, temp6, 67)
		temp6 += 4
	loop
	
	//70-74	Highlighted Actions
	SpriteFrame(0, -27, 15, 19, 256, 74)	//Fight
	SpriteFrame(0, -27, 16, 19, 275, 74)	//Act
	SpriteFrame(0, -27, 15, 19, 295, 74)	//Item
	SpriteFrame(0, -27, 16, 19, 314, 74)	//Spare
	SpriteFrame(0, -27, 15, 19, 334, 74)	//Defend	

	SpriteFrame(0, 0, 10, 10, 256, 94)	//Soul	75
	SpriteFrame(0, -6, 7, 5, 267, 94)	//HP	76
	SpriteFrame(0, -6, 21, 5, 275, 94)	//Mercy	77

	//delta numbers	but dark
	//78-87
	temp6 = 336
	while temp6 < 375
		SpriteFrame(26, -42, 3, 5, temp6, 67)
		temp6 += 4
	loop

	//Char Heads
	SpriteFrame(0, -6, 15, 14, 261, 34)	//88 Sonic
	SpriteFrame(0, -6, 13, 13, 406, 4)	//89 T
	SpriteFrame(0, -6, 16, 13, 405, 39)	//90 K
	SpriteFrame(0, -6, 16, 14, 405, 73)	//91 A

	SpriteFrame(0, -6, 22, 5, 267, 100)	//92 Press A

	SpriteFrame(0, -6, 54, 15, 256, 110)	//93 Sonic Bar

	SpriteFrame(0, -6, 3, 15, 311, 110)	//94 White Bar	

	//Damage Numbers
	//95-104
	temp6 = 369
	while temp6 < 478
		SpriteFrame(0, 0, 10, 10, temp6, 106)
		temp6 += 11
	loop

	SpriteFrame(-38, -38, 75, 75, 436, 129)	//105 Green Box

	SpriteFrame(-38, -38, 100, 48, 100, 213)	//106 Speech Bubble

	//big mc font
	//107-133
	temp5 = 142
	while temp5 < 157
		temp6 = 256
		while temp6 < 333
			SpriteFrame(0, 1, 5, 7, temp6, temp5)
			temp6 += 6
		loop
		temp5 += 8
	loop	

	//small mc font
	//134-158
	temp4 = 163
	while temp4 < 182
		temp3 = 256
		while temp3 < 333
			SpriteFrame(0, 0, 5, 9, temp3, temp4)
			temp3 += 6
		loop
		temp4 += 10
	loop	

	//but casteor why not use FX_FLIP?		idk?? i thought i'd need it for something more important but i guess not really? and im already too far in to remove this so
	SpriteFrame(-38, -38, 84, 48, 427, 254)	//159 Speech Bubble	Right

	//Text Numbers 0-9

	//160-169
	temp6 = 175
	while temp6 < 255
		SpriteFrame(-3, -6, 8, 7, temp6, 1)
		temp6 += 8
	loop

	SpriteFrame(-38, -38, 76, 84, 1, 427)	//170 Speech Bubble	Right	

	//Mercy Numbers
	//171 - 180
	temp6 = 369
	while temp6 < 478
		SpriteFrame(0, 0, 10, 10, temp6, 118)
		temp6 += 11
	loop	

	SpriteFrame(0, -6, 54, 15, 201, 164)	//181 T Bar
	SpriteFrame(0, -6, 54, 15, 201, 180)	//182 K Bar	
	SpriteFrame(0, -6, 54, 15, 201, 196)	//183 A Bar

	SpriteFrame(-80, -16, 160, 32, 306, 479)	//Game Over 184

	//Minecraft font
	SpriteFrame(0, 0, 5, 9, 262, 188)	//?	185
	SpriteFrame(0, 0, 5, 9, 256, 188)	//!	186

	switch stage.playerlistpos
	case 0
		SpriteFrame(3, -19, 30, 39, 1, 387)		//187 Fight 1
		SpriteFrame(3, -19, 34, 39, 1, 347)		//188 Fight 2
		SpriteFrame(3, -19, 30, 39, 32, 387)	//189 Fight 3
	break
	case 1
		SpriteFrame(0, -11, 32, 31, 64, 370)		//187 Fight 1
		SpriteFrame(0, -11, 26, 31, 97, 370)		//188 Fight 2
		SpriteFrame(0, -12, 31, 32, 124, 369)	//189 Fight 3
	break	
	case 2
		SpriteFrame(0, -19, 32, 39, 295, 439)		//187 Fight 1
		SpriteFrame(0, -20, 35, 40, 328, 438)		//188 Fight 2
		SpriteFrame(0, -18, 30, 38, 364, 440)	//189 Fight 3
	break	
	case 5
		SpriteFrame(0, -16, 24, 36, 395, 442)	//187 Idle
		SpriteFrame(0, -16, 40, 36, 420, 442)	//188 Idle
		SpriteFrame(0, -16, 27, 36, 461, 442)	//189 Idle
	break		
	end switch

	//Minecraft font			again			Grammar folks!
	SpriteFrame(0, 0, 5, 9, 286, 188)	//.	190
	SpriteFrame(0, 0, 5, 9, 268, 188)	//'	191

	SpriteFrame(-38, -38, 100, 48, 100, 164)	//192 Speech Bubble	Right Long

	SpriteFrame(0,0,64,66,164,273) //193 DPAD
	SpriteFrame(26,0,12,25,280,337) //194 DPAD up press
	SpriteFrame(26,0,12,26,280,374) //195 DPAD down press
	SpriteFrame(0,25,26,13,253,374) //196 DPAD left press
	SpriteFrame(0,25,26,13,253,388) //197 DPAD right press
	SpriteFrame(0,0,48,48,229,273) //198 A button
	SpriteFrame(0,0,48,48,229,322) //199 A button down

	SpriteFrame(0,0,48,48,115,298) //200 B button
	SpriteFrame(0,0,48,48,66,298) //201 B button down

	SpriteFrame(-38, -38, 100, 61, 295, 375)	//202 Speech Bubble	Right Long Tall

	//MC

	SpriteFrame(0, 0, 5, 9, 310, 188)  //203 // ,  yes really theres more

	// Place the HUD object into reserved object slot 4 and initialise its values
	Object[40].Type = TypeName[Delta Battle]
	
	// The object should always be run, regardless if it's within camera bounds or not
	Object[40].Priority = PRIORITY_ACTIVE
	
	// Make the HUD draw ontop of all other sprites, too
	Object[40].DrawOrder = 6

end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("IIZ/Objects1.gif")
	SpriteFrame(0, 0, 64, 64, 153, 154)
end event
